﻿using Architecture.Api.Application.Command.MenuCommand;
using Architecture.Domain;
using Architecture.Domain.RBAC;
using Architecture.Service;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.MenuHandler
{
    public class MenuUpdateCommandHandler : IRequestHandler<MenuUpdateCommand, int>
    {
        protected readonly IMenuService _menuService;

        public MenuUpdateCommandHandler(IMenuService menuService)
        {
            _menuService = menuService;
        }
        public async Task<int> Handle(MenuUpdateCommand request, CancellationToken cancellationToken)
        {
            return await _menuService.UpdateAsync(new Menu()
            {
                MenuId = request.MenuId,
                MenuName = request.MenuName,
                Url = request.Url,
                PId = request.PId,
                AddName = request.AddName,
                AddTime = request.AddTime,
            });
        }
    }
}
